package com.example.mapp.buildSql;

import com.example.entity.authority.PartyCheck;
import com.example.ext.entity.ExtMessageNotice;
import org.apache.ibatis.jdbc.SQL;

/**
 * Created by youkun on 2018/3/22.
 */
public class PartyCheckMappSql {

    public String queryPartyCheckList(PartyCheck partyCheck){

        String select = " id,party_Name,party_province,party_city,party_area,party_Addr," +
                "corporation,telephone,postal_Code,credit_Code,industry,contacts," +
                "contacts_Work,contacts_Card,contacts_Phone,contacts_Emile,contacts_Mobile," +
                "contacts_Address,business_License_Img,business_License_num,start_Time," +
                "success_Time,status,remarks,user_code,party_type,zzzs,zzdj ";
        String table =" party_check ";
        String whereParam="";

        if(partyCheck.getPartyName()!=null && partyCheck.getPartyName().length()>0){
            partyCheck.setPartyName("%"+partyCheck.getPartyName()+"%");
            whereParam+=" and party_name like #{partyName}";
        }
        if(partyCheck.getPartyProvince()!=null && partyCheck.getPartyProvince().length()>0){
            whereParam+=" and party_province = #{partyProvince}";
        }
        if(partyCheck.getPartyCity()!=null && partyCheck.getPartyCity().length()>0){
            whereParam+=" and party_city  = #{partyCity}";
        }
        if(partyCheck.getPartyArea()!=null && partyCheck.getPartyArea().length()>0){
            whereParam+=" and party_area = #{partyAre}";
        }
        if(partyCheck.getPartyType()!=null && partyCheck.getPartyType().length()>0){
            whereParam+=" and party_type = #{partyType}";
        }
        if(partyCheck.getStatus()!=null && partyCheck.getStatus().length()>0){
            whereParam+=" and status = #{status}";
        }

        String where = " 1=1 "+whereParam;
        String sql =  new SQL(){{
            SELECT(select);
            FROM(table);
            WHERE(where);
            ORDER_BY("id desc");
        }
        }.toString();

        return sql;
    }
}
